﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LEET.LEETCommon.Model;
using LEET.CommonInterfaces.TestControls;
using Compiled_Tests;
using System.Windows.Automation;
using LEET.LEETCommon.WidgetLookup;

namespace LEET.StandardModuals.Instructions
{
    public class Focus : Instruction
    {
        private string element;
        
        public Focus(string[] args)
            : base(args)
        {
            element = args[1].Trim();
        }

        public static Focus apply(String[] args)
        {
            return new Focus(args);
        }

        public static IAutomationActionResult StaticCall(IBox box, String widget)
        {
            AutomationElement ae = WidgetFinder.Find(widget, box.RootElement);
            ae.SetFocus();
            return new AutomationActionResult();
        }

        public override string PlainText()
        {
            return "Focus set on the element \"" + element + "\"";
        }

        public override string RenderStaticCall()
        {
            return "LEET.StandardModuals.Instructions.Focus.StaticCall(Box, \"" + element + "\")";
        }
    }
}
